using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Lesson18 : MonoBehaviour
{
    TextAsset t;
    // Start is called before the first frame update
    void Start()
    {
        // ResourceRequest rq = Resources.LoadAsync<TextAsset>("Text/Tex");
        //rq.completed += Complete;
        // StartCoroutine(Test());
        Lesson18work.Instance.Load<TextAsset>("Text/Tex", (a) =>
        {
            t = a;
        });
    }

    // Update is called once per frame
    void Update()
    {
        if (t != null)
        {
            print(t.text);
        }
    }
    void Complete(AsyncOperation rq)
    {
        print("finsh");
        t = (rq as ResourceRequest).asset as TextAsset;
    }
    IEnumerator Test()
    {
        ResourceRequest rq = Resources.LoadAsync<TextAsset>("Text/Tex");
        while(!rq.isDone)
        {
            print(rq.progress);
            yield return null;
        }
        t= rq.asset as TextAsset;

    }
}
